<template>
  <div>
    <el-form :model="form" label-width="180px">
        <el-form-item label="用户账号">
            <el-input v-model="form.userName"></el-input>
        </el-form-item>
        <el-form-item label="密码">
            <el-input v-model="form.password"></el-input>
        </el-form-item>
        <el-form-item label="用户年龄">
            <el-input v-model="form.age"></el-input>
        </el-form-item>
        <el-form-item label="用户生日">
            <el-input v-model="form.birthday"></el-input>
        </el-form-item>
        <el-form-item label="用户邮箱">
            <el-input v-model="form.email"></el-input>
        </el-form-item>
        <el-form-item label="用户性别">
            <el-input v-model="form.gender"></el-input>
        </el-form-item>
        <el-form-item label="用户电话">
            <el-input v-model="form.phoneNum"></el-input>
        </el-form-item>
        <el-form-item label="用户姓名">
            <el-input v-model="form.realName"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button @click="registerFn">register</el-button>
        </el-form-item>
    </el-form>
     <el-form :model="forms" label-width="180px">
        <el-form-item label="用户账号">
            <el-input v-model="forms.userName"></el-input>
        </el-form-item>
        <el-form-item label="密码">
            <el-input v-model="forms.password"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button @click="loginFn">login</el-button>
        </el-form-item>
    </el-form>
    <router-link to='/'>go</router-link>
    <div>{{this.$store.state.count}}</div>
    <div>{{counts}}</div>
    <div>{{this.$store.getters.counts}}</div>
    <el-button @click="fn">+1</el-button>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  data() {
    return {
        form: {

        },
        forms: {

        }
    }
  },
  computed: {
    ...mapState(['counts','count'])
  },
  methods: {
    fn() {
      this.$store.commit('countAdd')
    },
    loginFn() {
        this.$http.post('/user/login',this.forms).then(res => {
           console.log(res);
        })
    },
    registerFn() {
        this.$http.post('/user/save',this.form)
    }
  }
}
</script>

<style>

</style>